package o;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.webkit.WebView;
import com.huawei.hms.framework.network.restclient.hwhttp.HttpContants;
import com.huawei.hwCloudJs.JsClientApi;
import com.huawei.hwCloudJs.JsClientApi.SdkOpt.Builder;

public class bbg extends bbj {
    public String ˋ(Context context, WebView webView) {
        String createApi = JsClientApi.createApi(webView, new Builder().setShowAuthDlg(false).build());
        baz.ˏ();
        return createApi;
    }

    public azw ˏ(Context context, WebView webView) {
        azn ˋ = aze.ˋ();
        if (ˋ != null) {
            azw ˎ = ˋ.ˎ(context, this.ˋ, webView, azp.INTERNAL);
            if (ˎ != null) {
                webView.addJavascriptInterface(ˎ, "HiSpaceObject");
                return ˎ;
            }
        }
        return null;
    }

    public void ˏ(Context context, WebView webView, String str, boolean z) {
        if (!TextUtils.isEmpty(str) && webView != null) {
            if (ˊ()) {
                ˎ(context, webView, str);
            } else {
                ˋ(context, webView, str);
            }
        }
    }

    protected void ˋ(Context context, WebView webView, String str) {
        if (this.ॱॱ != null) {
            this.ॱॱ.ˎ(context, this.ˏ ? "buoy_webview" : "internal_webview", str);
        }
    }

    public boolean ˊ(Context context, WebView webView, String str) {
        ˋ(context, webView, str);
        return true;
    }

    public void ˊ(WebView webView) {
        if (webView != null) {
            Object url = webView.getUrl();
            if (TextUtils.isEmpty(url)) {
                azh.ˏ.ˏ("InternalWebViewLoadAction", "reload error , url empty");
            } else {
                ˎ(webView.getContext(), webView, url);
            }
        }
    }

    private void ˏ(Context context, WebView webView, String str) {
        byte[] ˋ;
        bab ˏ = ˏ();
        if (ˊ(str)) {
            ˋ = ˏ.ˋ(context, str, this.ˎ);
        } else {
            ˋ = ˏ.ˏ(context, str);
        }
        webView.postUrl(str, ˋ);
    }

    public boolean ˊ(Context context) {
        if (!(context instanceof Activity)) {
            return false;
        }
        ((Activity) context).finish();
        return true;
    }

    public void ॱ(WebView webView, String str, String str2) {
        if (!dof.ॱ(str) && webView != null) {
            if (HttpContants.HTTP_METHOD_GET.equals(str2) || "POST".equals(str2)) {
                this.ʻ = str2;
                ˎ(webView.getContext(), webView, str);
                return;
            }
            azh.ˏ.ˏ("InternalWebViewLoadAction", "loadCustomUrl method unknow:" + str2);
        }
    }

    private void ˎ(Context context, WebView webView, String str) {
        if (HttpContants.HTTP_METHOD_GET.equals(this.ʻ)) {
            webView.loadUrl(str);
        } else if ("POST".equals(this.ʻ)) {
            ˏ(context, webView, str);
        } else {
            azh.ˏ.ˏ("InternalWebViewLoadAction", "requestUrl method unknow:" + this.ʻ);
        }
    }
}
